import {
    reqGetSearchInfo
} from "@/api";

// search 仓库存储数据的地方
const state = {
    // 仓库初始状态
    searchList: {}
};
const mutations = {
    GETSEARCHLIST(state, searchList) {
        state.searchList = searchList;
    },
};
const actions = {
    // 获取search模块数据
    async getSearchList({
        commit
    }, params) {
        // params形参：是当用户派发action的时候，第二个参数传递过来的
        let result = await reqGetSearchInfo(params);
        if (result.code === 200) {
            commit("GETSEARCHLIST", result.data);
        }
    },
};
const getters = {
    goodsList(state) {
        return state.searchList.goodsList
    },
    trademarkList(state) {
        return state.searchList.trademarkList
    },
    attrsList(state) {
        return state.searchList.attrsList
    }
};

export default {
    state,
    mutations,
    actions,
    getters,
};